const baseURL = 'http://localhost:8889/app/';

export default function request(options){
    return new Promise((reslove,reject)=>{
      let user = wx.getStorageSync("userInfo");
      let coach = wx.getStorageSync("coachInfo");
      //判断用户是否登录
      if( user == '' && options.tag !== 'login' && coach == ''){
        wx.showToast({
          title: '请先登录',
          icon: 'error',
          duration: 1500,
          mask: true
        });
        return;
      }
      wx.request({
        url: baseURL+options.url,
        method: options.method||'get',
        data: options.data||{},
        header: {
          'content-type': 'application/json',
          // 'Authorization': 'Bearer ' + wx.getStorageSync('token')
        },
        success (res) {
          reslove(res)
        },
        fail(err){
            reject(err)
        }
      })
  })
}

